package com.fy.service.imbusiness.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.fy.common.entity.SkImUserInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fy.framework.common.model.R;
import com.fy.common.util.TokenUtil;
import com.fy.common.dto.UserDetailQueryDto;
import com.fy.common.dto.UserInfoCompleteDto;
import com.fy.common.dto.UserPwdModifyDto;
import com.fy.common.dto.UserSecrecySettingDto;
import com.fy.service.service.SkImUserInfoService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zhshuo
 * @date 2021/12/01 10:59
 **/
@Slf4j
@RestController
@AllArgsConstructor
@Api(tags = "用户信息控制")
@RequestMapping("/user")
public class SkImUserController {

    SkImUserInfoService userInfoService;

    /**
     * 个人信息
     * @return
     */
    @PostMapping("/info")
    @ApiOperation("用户个人基本信息获取")
    public R<?> info(){
        return R.success(userInfoService.selectOne(new EntityWrapper<SkImUserInfo>().eq("sk_im_user_id",TokenUtil.getUserId())));
    }

    /**
     * 用户信息修改
     * <li>头像</li>
     * <li>姓名</li>
     * <li>手机号</li>
     * <li>性别</li>
     * <li>生日</li>
     * <li>邮箱</li>
     * <li>地区</li>
     * <li>个性签名</li> 用户完成注册之后 填写的个人信息
     * 
     * @param infoCompleteDto
     *            基本个人信息
     * @return {@link R}
     */
    @PostMapping("/infoComplete")
    @ApiOperation("用户个人基本信息完善")
    public R<?> infoComplete(@RequestBody UserInfoCompleteDto infoCompleteDto) {
        return userInfoService.infoComplete(infoCompleteDto.setSkImUserId(TokenUtil.getUserId()));
    }

    /**
     * 密码修改
     * 
     * @param passwordModifyDto
     *            密码修改
     * @return {@link R}
     */
    @ApiOperation("密码修改")
    @PostMapping("/passwordModify")
    public R<?> passwordModify(@RequestBody UserPwdModifyDto passwordModifyDto) {
        return userInfoService.passwordModify(passwordModifyDto.setSkImUserId(TokenUtil.getUserId()));
    }

    /**
     * 隐私安全设置
     * 
     * @param secrecySettingDto
     *            隐私安全设置
     * @return {@link R}
     */
    @PostMapping("/secrecySetting")
    @ApiOperation("与隐私安全性相关的设置")
    public R<?> secrecySetting(@RequestBody UserSecrecySettingDto secrecySettingDto) {
        return userInfoService.secrecySetting(secrecySettingDto.setSkImUserId(TokenUtil.getUserId()));
    }

    /**
     * 陌生人资料查看
     * 
     * @return {@link R}
     */
    @PostMapping("/strangerDetail")
    @ApiOperation("陌生人资料查看")
    public R<?> strangerDetail(@RequestBody UserDetailQueryDto detailQueryDto) {
        return userInfoService.strangerDetail(detailQueryDto);
    }

}
